<?php 
/*导出excel表格*/
//header("Content-Type: text/html;charset=utf-8");
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel5.php';


$objExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel5($objExcel);
$objExcel->setActiveSheetIndex(0);
//$objExcel->getActiveSheet()->setTitle('信息');
//chr(ord('A')+count($result));

$letter = range('A','N');
static $row = 1;
$insert = function($data) use($objExcel,$letter,&$row){  
			for($i = 0;$i<count($data);$i++){
				$objExcel->getActiveSheet()->setCellValue("$letter[$i]".$row,"$data[$i]");
			};
			$row += 1;
 };
$header = array("姓名","性别","手机","职位","爱好");
$insert($header);
$data = array(array("fuck","f","1254645","p1","hobby"),array("fuck","f","1254645","p1","hobby"),array("fuck","f","1254645","p1","hobby"),array("fuck","f","1254645","p1","hobby"),array("fuck","f","1254645","p1","hobby"));
foreach ($data as $key => $data) {
 	$insert($data);
 };

unset($row);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header('Content-Disposition:attachment;filename="testdata.xls"');
header("Content-Transfer-Encoding:binary");
$objWriter->save('php://output');








?>